package com.lh.pospi.x_store.adapter;

import android.graphics.Color;
import android.support.annotation.Nullable;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.lh.pospi.x_store.R;
import com.lh.pospi.x_store.modle.BillBean;
import com.lh.pospi.x_store.modle.OrderBean;
import com.lh.pospi.x_store.utils.Constant;

import java.util.List;

public class OrderAdapter extends BaseQuickAdapter<BillBean,BaseViewHolder> {
    public OrderAdapter(int layoutResId, @Nullable List<BillBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, BillBean item) {
        helper.setText(R.id.item_id, "单号："+item.getBillno());
        helper.setText(R.id.item_status, item.getStatus().equals("0") ? "未上传" : "已上传");
        helper.setTextColor(R.id.item_status, item.getStatus().equals("0") ? Color.RED : Color.parseColor("#008577"));
        helper.setText(R.id.item_date, "日期："+item.getBillrq());
        helper.setText(R.id.item_market, "门店："+item.getMarketname());
        if (item.getType().equals(Constant.TYPE_D1) ||item.getType().equals(Constant.TYPE_RK)||item.getType().equals(Constant.TYPE_TC)) {
            helper.setText(R.id.item_sup, "供应商：" + item.getSupname());
        } else if (item.getType().equals(Constant.TYPE_PF) || item.getType().equals(Constant.TYPE_TH)) {
            helper.setText(R.id.item_sup, "客户：" + item.getSupname());
        } else if (item.getType().equals(Constant.TYPE_BS) ||
                item.getType().equals(Constant.TYPE_BY)||
                item.getType().equals(Constant.TYPE_BH)||item.getType().equals(Constant.TYPE_PD)) {
            helper.getView(R.id.item_sup).setVisibility(View.GONE);
        }else if (item.getType().equals(Constant.TYPE_DB) ) {
            helper.setText(R.id.item_market, "调入门店："+item.getMarketname());
            helper.setText(R.id.item_sup, "调出门店：" + item.getSupname());
        }


        helper.setText(R.id.item_memo, "备注：" + item.getMemo());
    }
}
